package com.zzy.mccjt.service.common.framework.exception;

import com.zzy.mccjt.service.common.framework.error.BaseError;
import com.zzy.mccjt.service.common.framework.error.impl.CommonError;
import lombok.Data;

/**
 * description:业务逻辑异常，当不符合业务逻辑时抛出些异常再由接口统一返回
 *
 * @author zzy
 * @version 1.0
 * @date 2020/4/3
 */
@Data
public class BusinessException extends RuntimeException {

    /***错误码*/
    private Integer errorCode;

    public BusinessException(String message) {
        super(message);
        this.errorCode = CommonError.UNKNOWN_ERROR.getCode();
    }
    public BusinessException(BaseError error) {
        super(error.getMessage());
        this.errorCode =error.getCode();
    }
    public BusinessException(Throwable throwable) {
        super(throwable.getMessage(),throwable);
        this.errorCode = CommonError.UNKNOWN_ERROR.getCode();
    }
    public BusinessException(Integer erorCode,String errorMsg) {
        super(errorMsg);
        this.errorCode = erorCode;
    }

}
